Skip to content

Preserve quaternion values during negation and coefficient export - #313

Open
kaushikgunasekaren wants to merge 2 commits into
rai-opensource:masterfrom
kaushikgunasekaren:fix-quaternion-values-nov19
Open

kaushikgunasekaren wants to merge 2 commits into
rai-opensource:masterfrom
kaushikgunasekaren:fix-quaternion-values-nov19

Conversation

@kaushikgunasekaren

Copy link
Copy Markdown

Bug

Unary negation always constructs a UnitQuaternion. For a general Quaternion, that changes the type and magnitude, and negating a zero quaternion fails. For a unit quaternion, constructor sign canonicalization can undo the requested negation.

The sequence coefficient properties (s, v, vec, vec_xyzs) also reconstruct each element through indexing, which canonicalizes negative scalar signs. As a result, reading a signed sequence can return coefficients different from the stored values, unlike reading a singleton.

Change

Negate the stored arrays into an empty result of the same class, without normalization. Read sequence coefficients directly from stored arrays. Constructor normalization policy and rotation equivalence are unchanged.

Validation

  • 36 focused regression/control cases: 20 fail before the fix; all 36 pass after it.
  • General and unit quaternions; positive/negative scalar signs; singleton, two-element, six-element and empty inputs; zero quaternion; double negation; magnitude/type preservation; independent result storage; all four coefficient properties; and signed values from the supported UnitQuaternion(Nx4, norm=False) constructor.
  • Full local suite: 602 passed, 3 skipped, 99 subtests passed (21 warnings), versus 566 passed on unchanged master.
  • Changed-file Black 23.10.0 and fatal flake8 checks pass. Whole-repository fatal lint has two pre-existing undefined-name findings in tests/test_dualquaternion.py.

AI assistance was used for investigation, implementation and tests. Validation is local Python testing only; no hardware validation is claimed.

Avoid constructor normalization when negating values and reading sequence coefficients.
Cover negation, magnitude, class, zero, empty sequences and stored coefficient exports.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant